package com.imageim.yimirror.ui.activity;

import android.os.CountDownTimer;
import android.view.View;
import android.widget.Button;

import com.imageim.yimirror.R;
import com.imageim.yimirror.base.BaseActivity;

import java.text.MessageFormat;

/**
 * 性别提示
 * Created by Administrator on 2018/1/2.
 */

public class GenderTipActivity extends BaseActivity {

    private Button btnClose;
    private CountDownTimer timer;

    @Override
    protected void initBundle() {
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_gender_tip;
    }

    @Override
    protected void initView() {
        btnClose = findViewById(R.id.btn_close_tip);
        btnClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void initData() {
        timer = new CountDownTimer(6000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                btnClose.setText(MessageFormat.format("关闭 {0}S", millisUntilFinished / 1000));
            }

            @Override
            public void onFinish() {
                finish();
            }
        };
        timer.start();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (timer != null) {
            timer.cancel();
        }
    }
}
